package com.penghk.contorller.web.resolver;

public class Page {

    /**
     * the default records per page
     */
    public static final int DEFAULT_EVERY_PAGE = 10;

    public static final int DEFAULT_FETCHING_TIMES = 3;

    /**
     * the default current page
     */
    public static int DEFAULT_CURRENT_PAGE = 1;

    /** imply if the page has previous page */
    private boolean prePage;

    /** imply if the page has next page */
    private boolean nextPage;

    /** the number of every page */
    private int everyPage;

    /** the total page number */
    private int totalPage;

    /** the number of current page */
    private int currentPage;

    /** the begin index of the records by the current query */
    private int beginIndex;

    /** the numbers of next pages to display */
    private int nextPages;

    /** the numbers of previous page to display */
    private int prePages;


    /** The default constructor */
    public Page() {

    }

    public Page(int currentPage, int everyPage) {
        this.currentPage = currentPage == 0 ? DEFAULT_CURRENT_PAGE : currentPage;
        this.everyPage = everyPage;
        this.beginIndex = (this.currentPage - 1) * everyPage;
    }

    public boolean isPrePage() {
        return prePage;
    }

    public void setPrePage(boolean prePage) {
        this.prePage = prePage;
    }

    public boolean isNextPage() {
        return nextPage;
    }

    public void setNextPage(boolean nextPage) {
        this.nextPage = nextPage;
    }

    public int getEveryPage() {
        return everyPage;
    }

    public void setEveryPage(int everyPage) {
        this.everyPage = everyPage;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getBeginIndex() {
        return beginIndex;
    }

    public void setBeginIndex(int beginIndex) {
        this.beginIndex = beginIndex;
    }

    public int getNextPages() {
        return nextPages;
    }

    public void setNextPages(int nextPages) {
        this.nextPages = nextPages;
    }

    public int getPrePages() {
        return prePages;
    }

    public void setPrePages(int prePages) {
        this.prePages = prePages;
    }
}
